package com.xbongbong.pro.common.pojo;/*/*/

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 *
 * @author 魏荣杰
 * @date 2019/5/13 15:55
 * @since v1.0
 * @version v1.0
 */
@Setter
@Getter
@ToString
public class AddressPojo {

    @NotNull(message = "省不可为空")
    private String province;

    @NotNull(message = "市不可为空")
    private String city;

    @NotNull(message = "区不可为空")
    private String district;

    @NotNull(message = "地址不可为空")
    private String address;

    @Valid
    private Location location;

    @Setter
    @Getter
    @ToString
    public class Location {

        @NotNull(message = "纬度不可为空")
        private Double lat;

        @NotNull(message = "经度不可为空")
        private Double lon;
    }

    /**
     *  设置经纬度
     * @param latitude 纬度
     * @param longtitude 经度
     */
    public void setLatAndLon (Double latitude,Double longtitude){
        Location location = new Location();
        location.setLat(latitude);
        location.setLon(longtitude);
        this.location = location;
    }
}
